Macromedia Flex Article

Learning Flex Basics (Part 2): Creating a Simple Calculator with Macromedia Flex


Robert Crooks

Robert Crooks

Macromedia Training

Table of Contents

  1. Introduction
  2. Building the Calculator
  3. Create the Application Object
  4. Add a Panel for the Calculator
  5. Add the Calculator Display
  6. Add a Grid to Lay Out the Buttons
  7. Add the Calculator Buttons
  8. Create the CalculatorController Class
  9. Add Properties to the Controller Class
  10. Add Controller Methods
  11. Instantiate the CalculatorController Class
  12. Complete Code Listing for calculator.mxml
  13. Complete Code Listing for CalculatorController.as
  14. Where to Go From Here

In this tutorial, you will build a working calculator in Macromedia Flex. Although the calculator is simple—it just adds, subtracts, multiplies, and divides—building it will enable you to work with several essential building blocks for Flex applications.

This tutorial is the second part in a four-part series written by Robert Crooks of the Macromedia Customer Training group:

If you prefer, you can download the entire set of tutorials.

If you like what you see and want to get more experience with Flex, Macromedia Customer Training offers Fast Track to Macromedia Flex, a two-day onsite training course to jump-start Flex development in your organization. Now let's get started!

What You Will Learn

  1. How to use the Application tag.
  2. How to use a Panel container.
  3. How to use Label controls.
  4. How to use Button controls.
  5. How to use a Grid container.
  6. How to create an ActionScript controller class for an MXML file.

Requirements

To complete this tutorial you will need to install the following software and files:

Macromedia Flex

(Installed and running on any server and platform supported by Flex. Note that the Flex trial is available on CD from the Macromedia store for $8.99. To learn more about the Flex trial, please read the Flex Frequently Asked Questions.)

Dreamweaver MX 2004 or a text editor that you can use to write XML and ActionScript code (a basic text editor such as Notepad is adequate)

Solution files for the tutorial:

Prerequisite knowledge:



About the author

Robert Crooks is the Director of Curriculum Development for Macromedia. He has written several courses on creating internet applications including the beta version of Fast Track to Macromedia Flex.